<!doctype html>
<head>
  <meta charset="utf-8">

  <title>My Bmob App</title>
  <meta name="description" content="My Bmob App">
  <meta name="viewport" content="width=device-width">
  <link rel="stylesheet" href="css/reset.css">
  <link rel="stylesheet" href="css/styles.css">
  <script type="text/javascript" src="jquery.min.js"></script>
  <script type="text/javascript" src="bmob.js"></script>
</head>

<body>
  
  <div id="main">
	<h1>开始Bmob之旅!</h1>

    <div style="display:none" class="error">
	  看起来保存对象时出现问题, 当调用<code>Bmob.initialize</code> 的时候，记得要先设置 Application ID 和 REST API Key 哦，亲！
    </div>

    <div style="display:none" class="success">
      <p>已经成功创建了第一个对象</p>
    </div>
  </div>

  <script type="text/javascript">

	//Bmob.initialize("Application ID", "REST API Key");
    Bmob.initialize("6939cca7f50b0f983ad317727a913cd3", "f4a3cd1e8ab7ec01cf87897cebd94798");
	
	var TestObject = Bmob.Object.extend("TestObject");
    var testObject = new TestObject();
      testObject.save({foo: "bar"}, {
      success: function(object) {
        $(".success").show();
      },
      error: function(model, error) {
        $(".error").show();
      }
    });
	
	/*
	//获取一行数据
	var GameScore = Bmob.Object.extend("GameScore");
    var query = new Bmob.Query(GameScore);
    query.get("4edc3f6ee9", {
      success: function(object) {
        // The object was retrieved successfully.
        alert(object.get("score"));
      },
      error: function(object, error) {
        alert("query object fail");
      }
    });
	*/
	
	/*
	//修改一行数据
	var GameScore = Bmob.Object.extend("GameScore");
    var query = new Bmob.Query(GameScore);
    query.get("4edc3f6ee9", {
      success: function(object) {
        // The object was retrieved successfully.
        object.set("score", 1338);
        object.save(null, {
          success: function(objectUpdate) {
            alert("create object success, object score:"+objectUpdate.get("score"));
          },
          error: function(model, error) {
            alert("create object fail");
          }
        });
      },
      error: function(object, error) {
        alert("query object fail");
      }
    });
	*/

	/*	
	//删除一行数据
	var GameScore = Bmob.Object.extend("GameScore");
    var query = new Bmob.Query(GameScore);
    query.get("4edc3f6ee9", {
      success: function(object) {
        // The object was retrieved successfully.
        object.destroy({
          success: function(deleteObject) {
          alert("delete success");
          },
          error: function(GameScoretest, error) {
          alert("delete fail");
          }
        });
      },
      error: function(object, error) {
        alert("query object fail");
      }
    });
	*/

	
  </script>
</body>

</html>
